<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../common/meta.jsp"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="s" uri="http://www.sweet.org/tags" %>

<div class="bg-light lter b-b wrapper-md">
	<h1 class="m-n font-thin h3">Query Page</h1>
</div>
<div class="wrapper-md">	
	<div class="panel panel-default">
		<div class="panel-heading">Organization info list</div>		
		<div class="table-responsive">
			<c:if test="${orglist.getTotal() == 0}">
				暂无相关数据
			</c:if>
			<table class="table table-striped b-t b-light zn-font">
				<thead>
					<tr>
						<th>ID</th>
						<th>Organization name</th>
						<th>Creat date</th>
						<th>Tenant shortname</th>
						<th>Users</th>
						<th style="width: 80px;">Active</th>
					</tr>
				</thead>
				<tbody>
					<c:forEach items="${orglist}" var="org" varStatus="status">
					<tr ng-click="isCollapsed${status.index} = !isCollapsed${status.index}" style="cursor: pointer;">
						<td>${org.orgId}</td>
						<td>${org.orgName}</td>
						<td><fmt:formatDate value="${org.orgCreatedon}" pattern="yyyy/MM/dd hh:mm:ss" /></td>
						<td>${org.sweetDemoTenant.tenantShortname}</td>
						<td>
							<c:forEach items="${org.userList}" var="user" begin="0" end="0">
								${user.userName}&nbsp;
							</c:forEach>
						</td>
						<td>
							<a href="#" <c:if test="${org.orgStatus}">class="active"</c:if> ui-toggle-class>
								<i class="fa fa-check text-success text-active"></i>
								<i class="fa fa-times text-danger text"></i>
							</a>
						</td>
					</tr>
					<tr collapse="isCollapsed${status.index}"><td colspan="6">
						<table class="w-full" style="color:#aaa">
							<c:forEach items="${org.userList}" var="user">
							<tr>
								<td width="10%" style="padding-top:5px;"><a class="media"><span class="pull-left thumb-sm"><img src="<s:url value='/resources/images/a0.jpg'/>" alt="..." class="img-circle"></span></a></td>
								<td width="25%" style="padding-left:7px;">${user.userName} (${user.userCode})</td> 
								<td width="24%" style="padding-left:2px;">手机号：${user.userMobile}</td>
								<td width="24%" style="padding-left:4px;">签名：${user.userSign}</td>
								<td style="padding-left:10px;">创建于：<fmt:formatDate value="${user.userCreatedon}" pattern="yyyy/MM/dd" /></td>
							</tr>
							</c:forEach>
						</table>
					</td></tr>
					</c:forEach>
				</tbody>
			</table>
		</div>
		
		<!-- 分页栏  -->
		<c:if test="${orglist.getTotal() > 6}">
		<footer class="panel-footer">
			<div class="row">
				<div class="col-sm-4 hidden-xs"></div>
				<div class="col-sm-4 text-center">
					<small class="text-muted inline m-t-sm m-b-sm">showing ${orglist.getStartRow()+1}-${orglist.getEndRow()>orglist.getTotal()?orglist.getTotal():orglist.getEndRow()} of ${orglist.getTotal()} items</small>
				</div>
				<div class="col-sm-4 text-right text-center-xs m-t-xs">
					<ul class="pagination pagination-sm m-t-none m-b-none">
						<li><a href="#" ui-sref="{pageNum:${orglist.getPageNum() - 1}}"><i class="fa fa-chevron-left"></i></a></li>
						<c:choose>  
							<c:when test="${orglist.getPages() < 6}">  
								<c:forEach var="i" begin="1" end="${orglist.getPages()}" step="1">	
									<li><a href="#" ui-sref="{pageNum:${i}}">${i}</a></li>
								</c:forEach>
							</c:when>  			
							<c:otherwise>
								<c:choose>    
								  	<c:when test="${orglist.getPageNum() < 4}">
								  		<li><a href="#" ui-sref="{pageNum:1}">1</a></li>
										<li><a href="#" ui-sref="{pageNum:2}">2</a></li>
										<li><a href="#" ui-sref="{pageNum:3}">3</a></li>
										<li><a href="#" ui-sref="{pageNum:4}">4</a></li>
										<li><a href="#">...</a></li>
										<li><a href="#" ui-sref="{pageNum:${orglist.getPages()}}">${orglist.getPages()}</a></li>
								  	</c:when>
								  	<c:otherwise>
									  	<c:if test="${orglist.getPageNum() > (orglist.getPages() - 3)}">
									  		<li><a href="#" ui-sref="{pageNum:1}">1</a></li>
									  		<li><a href="#">...</a></li>
											<li><a href="#" ui-sref="{pageNum:${orglist.getPages()-3}}">${orglist.getPages()-3}</a></li>
											<li><a href="#" ui-sref="{pageNum:${orglist.getPages()-2}}">${orglist.getPages()-2}</a></li>
											<li><a href="#" ui-sref="{pageNum:${orglist.getPages()-1}}">${orglist.getPages()-1}</a></li>
											<li><a href="#" ui-sref="{pageNum:${orglist.getPages()}}">${orglist.getPages()}</a></li>
									  	</c:if>
									  	<c:if test="${orglist.getPageNum() < (orglist.getPages() - 2)}">
									  		<li><a href="#" ui-sref="{pageNum:1}">1</a></li>
									  		<li><a href="#">...</a></li>
									  		<li><a href="#" ui-sref="{pageNum:${orglist.getPageNum()-1}}">${orglist.getPageNum()-1}</a></li>
									  		<li><a href="#" ui-sref="{pageNum:${orglist.getPageNum()}}">${orglist.getPageNum()}</a></li>
									  		<li><a href="#" ui-sref="{pageNum:${orglist.getPageNum()+1}}">${orglist.getPageNum()+1}</a></li>
									  		<li><a class="pagination-list" href="#">...</a></li>
											<li><a href="#" ui-sref="{pageNum:${orglist.getPages()}}">${orglist.getPages()}</a></li>
									  	</c:if>
								  	</c:otherwise>
							  	</c:choose>  	
							</c:otherwise>  
						</c:choose>
						<li><a href="#" ui-sref="{pageNum:${orglist.getPageNum() + 1}}"><i class="fa fa-chevron-right"></i></a></li>
					</ul>
				</div>
			</div>
		</footer>		
		</c:if>
		<!-- /分页栏  -->	
		
	</div>
</div>
